import { createClient, RedisClientType } from  'redis';



class RedisClient {

  client = createClient({
    url: `redis://${process.env.REDIS_DB_HOST}:${process.env.REDIS_DB_PORT}`,
    username: process.env.REDIS_USERNAME,
    password: process.env.REDIS_DB_PASSWORD,
  })
  
  connect = () => {
    this.client.connect();
    this.client.on('ready', () => {
      console.log('Redis Client connect successed');
    })
    this.client.on('error', (err) => {
      console.log('Redis Client Error', err);
      this.destory();
    })
  }

  get = (key: string, timestamps: number = 1000) => {

  }

  destory() {
    this.client.disconnect();
  }
}

export const redisClient = new RedisClient();
export default redisClient;


// export RedisClient.